#include<bits/stdc++.h>
using namespace std;
//const int MAXN = 1e9+5;
long long n, l, r, ans;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin >> n >> l >> r;
	if (r - n < l){
		ans = r % n;
	} else {
		int x = r % n;
		ans = (r-x-1) % n;
	}
	cout << ans << endl;
	return 0;
} 
